package test_system.user_logic;

import java.io.File;
import test_system.parser.ParserCSV;

/**
 * Created with IntelliJ IDEA. User: asus Date: 07.11.13 Time: 9:55 To change
 * this template use File | Settings | File Templates.
 */
public class Admin extends User {
    
    
     public Admin(String login, String password, String name) {
        this.login = login;
        this.password = password;
        this.name = name;
    }

    @Override
    public String toString() {
        return "login: " + getLogin() + ", name: " + getName();
    }

    public void addUser() {
        //TODO
    }

    private StringBuffer getStatistic(String login) {
        String fileName = login + "_statistic.txt";
        File f = new File(fileName);
        StringBuffer statistic;
        if (f.exists()) {
            ParserCSV parser = new ParserCSV();
            statistic = parser.parseFile(fileName);
            return statistic;
        } else {
            System.out.println("There is no statistics about this user");
            System.exit(0);
            return null;
        }
    }
    
    public void seeStatistic(String login){
        String[] statistics = getStatistic(login).toString().split(",");
        System.out.println(login + "'s statistic: ");
        for(int i = 0; i < statistics.length; i++){
            System.out.println("  " + i + ") " + statistics[i]);
        }
    }

    public String toWrite() {
        return getLogin() + "," + getPassword();
    }

    @Override
    public boolean isAdmin() {
        return true;
    }
}
